/*
 * AccountEvent.h
 *
 *  Created on: 24.07.2009
 *      Author: h3llfire
 */

#ifndef ACCOUNTEVENT_H_
#define ACCOUNTEVENT_H_

#include <wx/event.h>
#include "../Account.h"

namespace Impp {

enum AccountEventType
{
	ACCOUNT_EVENT_NEW_ACCOUNT,
	ACCOUNT_EVENT_ACCOUNT_CHANGED,
	ACCOUNT_EVENT_ACCOUNT_DELETED,
	ACCOUNT_EVENT_ACCOUNT_ACTIVATED,
	ACCOUNT_EVENT_ACCOUNT_DEACTIVATED
};



class AccountEvent : public wxNotifyEvent {
private:
	Account* account;
	AccountEventType type;

public:
	AccountEvent(Account* account, AccountEventType type, wxEventType eventType = wxEVT_NULL, int id = 0);
	virtual ~AccountEvent();

	virtual wxEvent* Clone()const;
	Account* getAccount() const;
	AccountEventType getAccountEventType()const;
};

typedef void(wxEvtHandler::*AccountEventFunction)(AccountEvent&);

BEGIN_DECLARE_EVENT_TYPES()
  DECLARE_EVENT_TYPE(EVT_ACCOUNT, -1)
END_DECLARE_EVENT_TYPES()


#define EVT_ACCOUNT_MACRO(id, fn) DECLARE_EVENT_TABLE_ENTRY(               \
		EVT_ACCOUNT, id, -1, (wxObjectEventFunction)               \
        (wxEventFunction)AccountEventFunction) & fn,                             \
        (wxObject*) NULL),

#define AccountEventHandler(func)                                                 \
        (wxObjectEventFunction)                                                \
        (wxEventFunction)wxStaticCastEvent(AccountEventFunction, &func)

}

#endif /* ACCOUNTEVENT_H_ */
